home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
UUCICO
/
ULIB14.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-03
|
19KB
|
488 lines
/*--------------------------------------------------------------------*/
/* u l i b 1 4 . c */
/* */
/* Serial port communications driver for ARTICOMM INT14 */
/* driver */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Copyright (c) Richard H. Lamb 1985-1987 */
/* */
/* Changes Copyright 1992 by Mark W. Schumann */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* This suite needs some tuning, but the Wonderworks lacks */
/* the time and more importantly the software to do so. */
/* Specific problems: */
/* */
/* The INT14 interface is not checked to be ARTICOMM, and */
/* thus the extensions to the generic INT14 functions may */
/* fail with no warning to the user. */
/* */
/* Non-ARTICOMM programs are not supported. */
/* */
/* No error is returned if a write times out */
/* */
/* Input data is discarded if a read times out, which */
/* will confuse the 'g' packet input processor. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: ulib14.c 1.3 1993/10/03 22:09:09 ahd Exp $
*
* $Log: ulib14.c $
* Revision 1.3 1993/10/03 22:09:09 ahd
* Use unsigned long to display speed
*
* Revision 1.2 1993/05/30 15:25:50 ahd
* Multiple driver support
*
*
* 30 Nov 92 - Adapt for use with INT14 drivers.
* Currently this is guaranteed to work only with
* Artisoft's ARTICOMM driver, but porting to others
* should be minor. Mods by Mark W. Schumann
* <mark@whizbang.wariat.org>
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <dos.h> /* Declares union REGS and int86(). */
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "hlib.h"
#include "ulib.h"
#include "comm.h" // Modem status bits
#include "ssleep.h"
#include "catcher.h"
#include "fossil.h" // Various INT14 definitions
#include "commlib.h" // Trace functions, etc.
/*--------------------------------------------------------------------*/
/* Internal prototypes */
/*--------------------------------------------------------------------*/
static void modemControl( char mask, boolean on);
static void ShowModem( void );
static unsigned char bps_table(int);
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
static BPS currentBPS;
static char currentDirect;
static boolean carrierDetect;
currentfile();
static boolean hangupNeeded = TRUE;
/*--------------------------------------------------------------------*/
/* b p s _ t a b l e */
/* */
/* Look up the INT14 baud rate value corresponding to (bps). */
/*--------------------------------------------------------------------*/
static unsigned char bps_table (int bps)
{
static int tab[] = {110, 150, 300, 600, 1200, 2400, 4800, 9600, -1};
unsigned char i;
for (i = 0; tab[i] > 0; i++)
{
if (tab[i] == bps)
return i;
}
return 255;
} /* bps_table */
/*--------------------------------------------------------------------*/
/* i o p e n l i n e */
/* */
/* Open the serial port for I/O */
/*--------------------------------------------------------------------*/
int iopenline(char *name, BPS bps, const boolean direct)
{
if (portActive) /* Was the port already active? */
closeline(); /* Yes --> Shutdown it before open */
printmsg(15, "openline: %s, %lu", name, bps);
currentDirect = (char) (direct ? 'D' : 'M');
if (sscanf(name, "COM%d", &portNum) != 1)
{
printmsg(0,"Communications port must be format COMx, was %s",
name);
panic();
}
norecovery = FALSE; // Flag we need a graceful shutdown after
// Cntl-BREAK
/*--------------------------------------------------------------------*/
/* With the INT14 setup, we don't worry about the lock file */
/* since our modem sharing software is supposed to deal with */
/* resource contention. */
/*--------------------------------------------------------------------*/
portNum--; /* Change ordinal number to offset */
SIOSpeed( bps ); /* Open the port and set the speed */
flowcontrol( FALSE ); /* Enable hardware flow control */
ssleep(2); /* Wait two seconds as required by V.24 */
carrierDetect = FALSE; /* No modem connected yet */
traceStart( name );
portActive = TRUE; /* record status for error handler */
return 0; // Return success to caller
} /* iopenline */
/*--------------------------------------------------------------------*/
/* i s r e a d */
/* */
/* Read from the serial port */
/* */
/* Non-blocking read essential to "g" protocol. See */
/* "dcpgpkt.c" for description. This all changes in a */
/* multi-tasking system. Requests for I/O should get queued */
/* and an event flag given. Then the requesting process (e.g. */
/* gmachine()) waits for the event flag to fire processing */
/* either a read o